/*
 * Game Theory.
 * Do it from the last person to the first one.
 */
#include <iostream>
#include <cstdio>
using namespace std;

int pref[105][8];
/*
 * For each choice[i][j], if the i-th person changes the
 * status to j, which result will he get in the end.
 */
int choice[105][8];

int next[8][3];

void init()
{
	for(int i = 0;i<8;i++)
	{
		for(int j = 0;j<3;j++)
		{
			next[i][j] = i ^ (1 << j);
		}
	}
}

int get_most_pref(int x, int y, int z, int k)
{
	int ret = x;
	ret = pref[k][ret] < pref[k][y] ? ret : y;
	ret = pref[k][ret] < pref[k][z] ? ret : z;
	return ret;
}

void solve()
{
	int n;
	scanf("%d", &n);
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<8;j++)
		{
			scanf("%d", &pref[i][j]);
		}
	}

	for(int i = 0;i<8;i++)
	{
		choice[n - 1][i] = i;
	}

	int x, y, z;
	for(int i = n - 2;i>=0;--i)
	{
		for(int j = 0;j<8;j++)
		{
			x = choice[i + 1][next[j][0]];
			y = choice[i + 1][next[j][1]];
			z = choice[i + 1][next[j][2]];

			choice[i][j] = get_most_pref(x, y, z, i + 1);
		}
	}

	x = choice[0][next[0][0]];
	y = choice[0][next[0][1]];
	z = choice[0][next[0][2]];

	int result = get_most_pref(x, y, z, 0);

	for(int i = 2;i>=0;--i)
	{
		printf("%c", result & (1 << i) ? 'Y' : 'N');
	}
	printf("\n");
}

int main()
{
	freopen("data.in", "r", stdin);
	init();

	int t;
	scanf("%d", &t);

	for(int i = 0;i<t;i++)
	{
		solve();
	}
	return 0;
}
